import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    //二级路由配置
    children: [{
      path: 'products',
      component: () => import('../views/ProductsList.vue')
    }, {
      path: 'add',
      component: () => import('../views/ProductsEdit.vue')
    }, {
      path: 'edit',
      component: () => import('../views/ProductsEdit.vue')
    }]
  },

]

const router = new VueRouter({
  mode: "history",
  routes
})

export default router